<template>
    <a-modal :maskClosable="true" :title="title" :visible="visible" width=800 @cancel="cancel" @ok="handleOk">
        <a-card :bordered="false">
            <!-- 查询区域 -->
            <div class="table-page-search-wrapper">
                <a-form layout="inline" @keyup.enter.native="searchQuery">
                    <a-row :gutter="24">
                        <a-col :xl="6" :lg="7" :md="8" :sm="24">
                            <a-form-item label="外围系统名">
                                <a-input placeholder="请输入外围系统名" v-model="queryParam.exoSystemCode"></a-input>
                            </a-form-item>
                        </a-col>
                        <a-col :xl="6" :lg="7" :md="8" :sm="24">
                            <a-form-item label="接口类型">
                                <a-input placeholder="请输入接口类型" v-model="queryParam.serverType"></a-input>
                            </a-form-item>
                        </a-col>
                        <template v-if="toggleSearchStatus">
                            <a-col :xl="6" :lg="7" :md="8" :sm="24">
                                <a-form-item label="外围服务名">
                                    <a-input placeholder="请输入外围服务名" v-model="queryParam.exoServerCode"></a-input>
                                </a-form-item>
                            </a-col>
                        </template>
                        <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
                        </a-col>
                    </a-row>
                </a-form>
            </div>
            <!-- 查询区域-END -->
            <!--用户列表-->
            <a-table
                    ref="table"
                    size="small"
                    rowKey="id"
                    :columns="columns"
                    bordered
                    :dataSource="dataSource"
                    :pagination="ipagination"
                    :loading="loading"
                    :rowSelection="rowSelection"
                    class="j-table-force-nowrap"
                    @change="handleTableChange"
            >
            </a-table>
        </a-card>


    </a-modal>
</template>

<script>
    import { JeecgListMixin } from '@/mixins/JeecgListMixin'

    export default {
        name: 'MsiServerSelectPop',
        mixins: [JeecgListMixin],
        components: {},
        data() {
            return {
                visible: false,
                title: '外围服务接口选择',
                columns: [
                    {
                        title: '#',
                        dataIndex: '',
                        key:'rowIndex',
                        width:60,
                        align:"center",
                        customRender:function (t,r,index) {
                            return parseInt(index)+1;
                        }
                    },
                    {
                        title:'单位简称',
                        align:"center",
                        dataIndex: 'orgCode'
                    },
                    {
                        title:'单位全称',
                        align:"center",
                        dataIndex: 'orgName'
                    },
                    {
                        title:'系统简称',
                        align:"center",
                        dataIndex: 'exoSystemCode'
                    },
                    {
                        title:'系统全称',
                        align:"center",
                        dataIndex: 'exoSystemName'
                    },
                    {
                        title:'接口类型',
                        align:"center",
                        dataIndex: 'exoServerType'
                    },
                    {
                        title:'外系统服务名',
                        align:"center",
                        dataIndex: 'exoServerCode'
                    },
                    {
                        title:'外系统服务描述',
                        align:"center",
                        dataIndex: 'exoServerDesc'
                    },
                ],
                defQueryParam: { status: '1' },
                url: {
                    list: "/msibase/msiExoServer/list",
                },
            }
        },
        computed: {
            rowSelection() {
                return {
                    //type: 'checkbox',
                    type: 'radio',
                    selectedRowKeys: this.selectedRowKeys,
                    onChange: (selectedRowKeys, selectedRows) => {
                        this.onSelectChange(selectedRowKeys, selectedRows)
                    },
                }
            }
        },
        methods: {
            hide() {
                this.visible = true
                this.queryParam = this.defQueryParam
                this.loadData()
                this.onClearSelected()
            },
            cancel() {
                this.visible = false
            },
            handleOk() {
                const that = this
                let selectionRows = this.selectionRows
                if (selectionRows.length == 0) {
                    this.$message.error('尚未选择任何明细')
                }
                this.$emit('ok', selectionRows)
                this.visible = false
            },
            searchQuery() {
                this.queryParam = Object.assign({}, this.defQueryParam, this.queryParam)
                this.loadData(1)
            },
            searchReset() {
                this.queryParam = this.defQueryParam
                this.loadData(1)
            },
        }
    }
</script>

<style scoped>
</style>
